﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class SystemManage_AdminOptionsOther : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            tbCompany.Text = PublicFunction.GetOptionsAsString("公司名称");

            tb1.Text = PublicFunction.GetOptionsAsString("OnlinePay_Alipay_UserName").ToString();
            tb2.Text = PublicFunction.GetOptionsAsString("OnlinePay_Alipay_UserNumber").ToString();
            tb3.Text = PublicFunction.GetOptionsAsString("OnlinePay_Alipay_MD5Key").ToString();
            tb4.Text = PublicFunction.GetOptionsAsString("OnlinePay_Alipay_PayFormalitiesFeesScale").ToString();
            tb5.Text = PublicFunction.GetOptionsAsString("OnlinePayOut_99Bill_MD5Key").ToString();
            tb6.Text = ShoveEL._Convert.StrToInt(PublicFunction.GetOptionsAsString("OnlinePayOut_99Bill_DistillFormalitiesFeesScale"), 0).ToString();

            tbOnlinePayOut_Alipay_UserName.Text = PublicFunction.GetOptionsAsString("OnlinePayOut_Alipay_UserName").ToString();
            tbOnlinePayOut_Alipay_UserNumber.Text = PublicFunction.GetOptionsAsString("OnlinePayOut_Alipay_UserNumber").ToString();
            tbOnlinePayOut_Alipay_RealityName.Text = PublicFunction.GetOptionsAsString("OnlinePayOut_Alipay_RealityName").ToString();
            tbOnlinePayOut_Alipay_MD5Key.Text = PublicFunction.GetOptionsAsString("OnlinePayOut_Alipay_MD5Key").ToString();

            tb7.Text = PublicFunction.GetOptionsAsString("EmailServer_From");
            tb8.Text = PublicFunction.GetOptionsAsString("EmailServer_EmailServer");
            tb9.Text = PublicFunction.GetOptionsAsString("EmailServer_User");
            tb10.Text = PublicFunction.GetOptionsAsString("EmailServer_Password");

            tb11.Text = PublicFunction.GetOptionsAsString("ISP_HostName");
            tb12.Text = PublicFunction.GetOptionsAsString("ISP_HostPort");
            tb13.Text = PublicFunction.GetOptionsAsString("ISP_UserID");
            tb14.Text = PublicFunction.GetOptionsAsString("ISP_UserPassword");
            tb15.Text = PublicFunction.GetOptionsAsString("ISP_RegCode");
            tb16.Text = PublicFunction.GetOptionsAsString("ISP_ServiceNumber");

            tb3.Attributes.Add("value", tb3.Text);
            tb5.Attributes.Add("value", tb5.Text);
            tb10.Attributes.Add("value", tb10.Text);
            tb14.Attributes.Add("value", tb14.Text);
            tbOnlinePayOut_Alipay_MD5Key.Attributes.Add("value", tbOnlinePayOut_Alipay_MD5Key.Text);

            btnGO.Attributes.Add("onclick", "return confirm('" + System.Web.HttpUtility.HtmlEncode("您确信输入无误，并且立即保存吗？") + "');");
        }
    }

    #region Web 窗体设计器生成的代码

    override protected void OnInit(EventArgs e)
    {
        isRequestLogin = true;
        RequestCompetences = Competences.BuildCompetencesList(Competences.Options);
        RequestLoginPage = "SystemManage/AdminOptionsOther.aspx";

        base.OnInit(e);
    }

    #endregion

    protected void btnGO_Click(object sender, EventArgs e)
    {
        double Value4 = ShoveEL._Convert.StrToDouble(tb4.Text, 0);
        if (Value4 < 0)
        {
            ShoveEL._Web.JavaScript.Alert(this.Page, "支付手续费设置错误。");
            return;
        }

        int Value6 = ShoveEL._Convert.StrToInt(tb6.Text, 0);
        if (Value6 < 0)
        {
            ShoveEL._Web.JavaScript.Alert(this.Page, "派款手续费设置有误。");
            return;
        }


        //开始设置
        PublicFunction.SetOptions("公司名称", tbCompany.Text.Trim());

        PublicFunction.SetOptions("OnlinePay_Alipay_UserName", tb1.Text.Trim());
        PublicFunction.SetOptions("OnlinePay_Alipay_UserNumber", tb2.Text.Trim());
        PublicFunction.SetOptions("OnlinePay_Alipay_MD5Key", tb3.Text.Trim());
        PublicFunction.SetOptions("OnlinePay_Alipay_PayFormalitiesFeesScale", Value4.ToString());
        PublicFunction.SetOptions("OnlinePayOut_99Bill_MD5Key", tb5.Text.Trim());
        PublicFunction.SetOptions("OnlinePayOut_99Bill_DistillFormalitiesFeesScale", Value6.ToString());

        PublicFunction.SetOptions("OnlinePayOut_Alipay_UserName", tbOnlinePayOut_Alipay_UserName.Text.Trim());
        PublicFunction.SetOptions("OnlinePayOut_Alipay_UserNumber", tbOnlinePayOut_Alipay_UserNumber.Text.Trim());
        PublicFunction.SetOptions("OnlinePayOut_Alipay_RealityName", tbOnlinePayOut_Alipay_RealityName.Text.Trim());
        PublicFunction.SetOptions("OnlinePayOut_Alipay_MD5Key", tbOnlinePayOut_Alipay_MD5Key.Text.Trim());

        PublicFunction.SetOptions("EmailServer_From", tb7.Text.Trim());
        PublicFunction.SetOptions("EmailServer_EmailServer", tb8.Text.Trim());
        PublicFunction.SetOptions("EmailServer_User", tb9.Text.Trim());
        PublicFunction.SetOptions("EmailServer_Password", tb10.Text.Trim());

        PublicFunction.SetOptions("ISP_HostName", tb11.Text.Trim());
        PublicFunction.SetOptions("ISP_HostPort", tb12.Text.Trim());
        PublicFunction.SetOptions("ISP_UserID", tb13.Text.Trim());
        PublicFunction.SetOptions("ISP_UserPassword", tb14.Text.Trim());
        PublicFunction.SetOptions("ISP_RegCode", tb15.Text.Trim());
        PublicFunction.SetOptions("ISP_ServiceNumber", tb16.Text.Trim());

        //写入操作日志
        OperationLog Log = new OperationLog();

        Log._Memo = _User.Name + " 设置系统选项（其他）";
        Log._OpDateTime = DateTime.Now;
        Log._UserID = _User.ID;
        Log._UserIP = System.Web.HttpContext.Current.Request.UserHostAddress;

        Log.Add();
        //操作日志写入完成

        ShoveEL._Web.JavaScript.Alert(this.Page, "设置成功。");
    }
}
